package singleton;

/**
 * @program: javase
 * @description: 使用静态内部类,因为静态内部类在Singleton3加载时不初始化，而是在调用的时候初始化，
 * 即不会浪费资源，也可通过类加载机制保证线程安全
 * @author: luolidong
 * @create: 2021-06-12 15:40
 * @version: 1.0
 */
public class Singleton3 {
    private Singleton3() {
    }
    private static class SInstance{
        public static final Singleton3 instance = new Singleton3();
    }
    public static Singleton3 getInstance(){
        return SInstance.instance;
    }

}
